from django.db import models

class Estado(models.Model):
    sigla = models.CharField(max_length=2)
    nome = models.CharField(max_length=40)
    def __unicode__(self):
        return (self.sigla)
    
class Cidade(models.Model):
    sigla = models.CharField(max_length=2)
    nome = models.CharField(max_length=40)
    estado = models.ForeignKey(Estado)
    def __unicode__(self):
        return (self.nome)

class Profissao(models.Model):
    descricao = models.CharField(max_length=50)
    def __unicode__(self):
        return (self.descricao)
        
class Potencia(models.Model):
    sigla = models.CharField(max_length=10)
    descricao = models.CharField(max_length=50)
    def __unicode__(self):
        return (self.sigla)
    
class Rito(models.Model):
    sigla = models.CharField(max_length=50)
    descricao = models.CharField(max_length=50)
    def __unicode__(self):
        return (self.sigla)
    
class Loja(models.Model):
    nome = models.CharField(max_length=50)
    rito = models.ForeignKey(Rito)
    potencia = models.ForeignKey(Potencia)
    numero_loja = models.CharField(max_length=10)
    reuniao = models.CharField(max_length=100)
    telefone_comercial = models.CharField(max_length=40, blank=True)
    #'ENDERECO'
    rua = models.CharField(max_length=40)
    numero = models.CharField(max_length=10)
    complemento = models.CharField(max_length=40, blank=True)
    cep = models.CharField(max_length=10)
    bairro = models.CharField(max_length=40)
    cidade = models.ForeignKey(Cidade)
    def __unicode__(self):
        return (self.nome)

class Pessoa(models.Model):
    nome = models.CharField(max_length=50)    
    tipos_sangue = (
                    ('A POSITIVO','A+'),
                    ('A NEGATIVO','A-'),
                    ('B POSITIVO','B+'),
                    ('B NEGATIVO','B-'),
                    ('O POSITIVO','0+'),
                    ('O NEGATVO','O-'),
                    ('AB POSITIVO','AB+'),
                    ('AB NEGATIVO','AB-'),
                    )    
    tipo_sanguineo = models.CharField(max_length=20, choices = tipos_sangue)
    loja = models.ForeignKey(Loja)
    #'DADOS PESSOAIS'
    data_de_nascimento = models.DateField()
    telefone_residencial = models.CharField(max_length=40)
    telefone_comercial = models.CharField(max_length=40, blank=True)
    celular = models.CharField(max_length=40, blank=True)
    email = models.EmailField()
    profissao = models.ForeignKey(Profissao)
    #'ENDERECO'
    rua = models.CharField(max_length=40)
    numero = models.CharField(max_length=10)
    complemento = models.CharField(max_length=40, blank=True)
    cep = models.CharField(max_length=10)
    bairro = models.CharField(max_length=40)
    cidade = models.ForeignKey(Cidade)
    status = models.BooleanField()
    def ativo(self):
        if (self.status == True):
            return 'Ativo'
        else:
            return 'Inativo'
        
